<template>
  <div>
    <el-form :model="searchForm" inline label-width="80px">
      <el-form-item label="角色名称">
        <el-input v-model="searchForm.roleName" clearable placeholder="模糊匹配角色名称"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getDataList">搜索</el-button>
        <el-button @click="clearForm">清空</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="dataList" border>
      <el-table-column prop="id" label="编号" align="center"/>
      <el-table-column prop="roleName" label="角色名称" align="center"/>
      <el-table-column prop="profile" show-overflow-tooltip label="介绍" align="center"/>
    </el-table>
  </div>
</template>

<script>
export default {
  name: 'RoleList',
  data () {
    return {
      searchForm: {
        roleName: ''
      },
      dataList: []
    }
  },
  methods: {
    getDataList () {
      this.$http.get('role/select', this.searchForm).then(data => {
        if (data) {
          this.dataList = [...data]
        }
      })
    },
    clearForm () {
      this.searchForm = {
        roleName: ''
      }
      this.getDataList()
    }
  },
  created () {
    this.getDataList()
  }
}
</script>

<style scoped>

</style>
